Spring Data by Mark Pollack Oliver Gierke Thomas Risberg Jon Brisbin & Michael Hunger

Spring Data by Mark Pollack Oliver Gierke Thomas Risberg Jon Brisbin & Michael Hunger

Author:Mark Pollack, Oliver Gierke, Thomas Risberg, Jon Brisbin & Michael Hunger [Mark Pollack, Oliver Gierke, Thomas Risberg, Jon Brisbin, and Michael Hunger]
Language: eng
Format: epub, pdf
Tags: COMPUTERS / Database Management / Data Mining
ISBN: 9781449323943
Publisher: O'Reilly Media
Published: 2012-10-11T16:00:00+00:00


The first thing to notice here is that we triggered the curl command with the -v flag. This flag activates verbose output, listing all the request and response headers alongside the actual response data. We see that the server returns data of the content type application/json by default. The actual response body contains a set of links we can follow to explore the application. Each of the links provided is actually derived from a Spring Data repository available in the ApplicationContext. We have a CustomerRepository, a ProductRepository, and an OrderRepository, so the relation type (rel) attributes are customer, product, and order (the first part of the repository name beginning with a lowercase character). The resource URIs are derived using that default as well. To customize this behavior, you can annotate the repository interface with @RestResource, which allows you to explicitly define path (the part of the URI) as well as the rel (the relation type).

Links

The representation of a link is usually derived from the link element defined in the Atom RFC. It basically consists of two attributes: a relation type (rel) and a hypertext reference (href) . The former defines the actual semantics of the link (and thus has to be documented or standardized), whereas the latter is actually opaque to the client. A client will usually inspect a link’s response body for relation types and follow the links with relation types it is interested in. So basically the client knows it will find all orders behind links with a rel of order. The actual URI is not relevant. This structure results in decoupling of the client and the server, as the latter tells the client where to go. This is especially useful in case a URI changes or the server actually wants to point the client to a different machine to load-balance requests.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.